<!--
 * @FilePath     : /study_code/layui/18-12.html
 * @Description  : click配置项：节点被点击的回调
 * @Date         : 2025-04-10 16:34:50
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-10 16:37:05
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
  </head>
  <body>
    <div id="test1"></div>

    <script src="/layui/dist/layui.js"></script>
    <script src="/layui/tree/common.js"></script>
    <script>
      layui.use('tree', function () {
        var tree = layui.tree,
          $ = layui.$

        //渲染
        var inst1 = tree.render({
          elem: elem,
          data: data,
          id: 'theTree',

          /**
           * @brief: “节点”被点击的回调；
           * @param {*} obj 事件处理函数返回的对象；
           * obj.data 当前点击的节点数据；
           * obj.state 当前节点的展开状态：open、close、normal；
           * obj.elem 当前节点元素；
           * obj.data.children 当前节点下是否有子节点；
           * !tips: 子节点 点击也会触发此事件， obj返回的参数不一；
           */
          click: function ({data, state, elem}) {
            console.log(obj)
            console.log(data)
            console.log(state)
            console.log(elem)
            console.log(data.children)
          },
        })
      })
    </script>
  </body>
</html>
